#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/3/27 20:22
# @Author  : Rem~
# @File    : CreateAsinSingal02.py
# @function: class类的使用


import numpy as np
import matplotlib.pyplot as plt

class



# sample frequency
fs = 100
# signal frequency
f = 1
# sample point
N = 2**10
# x axis
x = np.linspace(1, N, N)
# x = range(1, N)
# amplitude
amp = 2**12
sig = amp*np.sin(2*np.pi*f*(x/fs))

fig, axs = plt.subplots(2, 1)
axs[0].plot(x, sig, "-b")
axs[0].set(xlabel="sample point", ylabel="signal amplitude(LSB)", \
           title="Time domain signal")
axs[0].grid(True)

sig_fft = np.fft.fft(sig)
sig_fft_abs = np.abs(sig_fft)/N*2
axs[1].plot(x[0:int(N/2)-1]*(fs/N), sig_fft_abs[0:int(N/2)-1])
axs[1].set(xlabel="frequency axis(MHz)", ylabel="signal amplitude(LSB)")
axs[1].grid(True)

fig.tight_layout()
plt.show()
